<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="jpa.*"%>
<%@ page import="pkg.*"%>
<%@ page import="java.util.*"%>

<%
	IStatelessBean statelessBean = (IStatelessBean) session
			.getAttribute("statelessBean");
	IStatefulBean statefulBean = (IStatefulBean) session
			.getAttribute("statefulBean");

	Page currentPage = statefulBean.getCurrentPage();	
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<link href="default.css" rel="stylesheet" type="text/css" />
	<title><%=currentPage.getPgTitle()%></title>
</head>
<body>
	<div id="wrapper">
	
		<div class="content">
		<h1><%=currentPage.getPgTitle()%></h1>
		
		<%
			if (statelessBean.isMenuPage(currentPage))
			{
				List<Link> menuLinks = statelessBean.getMenuLinks(currentPage);
				for (int i = 0; i < menuLinks.size(); i++)
				{
					Link l = menuLinks.get(i);
					int numberInRow = 3;
					if(i > (menuLinks.size()/3)*3 - 1) numberInRow = menuLinks.size()%3;
					int column = i%3;
					if(numberInRow == 3) 
					{
						%>
						<a href="Controller?do=test&amp;id=<%=l.getPage1().getPgId()%>">
						<div class="menuLink">
						<%=l.getPage1().getPgTitle()%>
						</div>
						</a>
						<%
					}
				}
			} 
			else
			{
				if (statelessBean.isAppletPage(currentPage))
				{
			%>
				<applet <%=currentPage.getPgContent()%>>
					Your browser does not support the <code>applet</code> tag.
				</applet> 
			<script type="text/javascript" src="<%=currentPage.getPgContent()%>"></script>
			<%
				}
			
				else if (statelessBean.isImagePage(currentPage))
				{
					%>
					<img src = "<%=currentPage.getPgContent()%>" />
					<%
				}
				else if (statelessBean.isVideoPage(currentPage))
				{
					%>
					<iframe class = "video" width="560" height="315" src="<%=currentPage.getPgContent()%>" frameborder="0" allowfullscreen"></iframe>
					<%
				}
				else if (statelessBean.isTextPage(currentPage))
				{
					%><%=currentPage.getPgContent()%><%
				}
			}
	
		%>
			<p class="clear"/>
			<p>Page content:</p><%=currentPage.getPgContent()%>
		
			</div>
			<p class = "clear"/>
			<div class="footer">
			
			<%@ include file="toolbar.jsp"%>
			<%@ include file="footer.jsp"%>
		</div>
	</div>	
</body>
</html>